<include file="default/public/header_common" />

<div class="am-container" style="padding-top: 2rem;padding-bottom: 2rem;"> <a class="am-btn am-btn-danger am-radius am-btn-block" href="{:U('Wap/Users/editAddress')}?cartId={$cartId}">新增收货地址+</a> </div>
<volist name="lists" id="vo">
<div class="address-item">
  <div class="ai-top">
    <h3>{$vo.userName}   {$vo.userPhone}   <if condition="$vo.isDefault == 1"><span class="am-badge am-badge-danger am-round">默认地址</span><else /><span class="am-badge am-badge-warning am-round" onClick="setDefault({$vo.addressId})">设为默认地址</span></if><if condition="!empty($cartId)"><a href="{:U('Wap/Order/checkOrder')}?cartId={$cartId}&adrid={$vo.addressId}"><span class="am-badge am-badge-primary am-round am-fr">选择地址</span></a></if></h3>
    <p>{$vo.province} {$vo.city} {$vo.district}</p>
    <p>{$vo.address}</p>
  </div>
  <div class="am-g ai-bottom am-text-center">
    <div class="am-u-sm-6" style="border-right: 1px solid #dddddd;"><a href="{:U('Wap/Users/editAddress/id/' . $vo['addressId'])}?cartId={$cartId}"><i class="am-icon-edit"></i> 修改</a></div>
    <div class="am-u-sm-6" id="doc-confirm-toggle" onClick="delAddress({$vo.addressId})"><i class="am-icon-trash"></i> 删除</div>
  </div>
</div>
</volist>
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-bd f-small"> 若一旦确定删除地址，就无法恢复收货地址。 </div>
    <div class="am-modal-footer"> <span class="am-modal-btn" data-am-modal-cancel>取消</span> <span class="am-modal-btn" data-am-modal-confirm>确定</span> </div>
  </div>
</div>
<script src="__ROOT__/Apps/Wap/View/default/assets/js/jquery.min.js"></script> 
<script src="__ROOT__/Apps/Wap/View/default/assets/js/amazeui.min.js"></script> 
<script src="__PUBLIC__/js/common.js"></script>
<script>
function setDefault(id) {
	$.post("{:U('Wap/Users/setDefaultAddress')}",{addressId:id},function(data,textStatus){
		var json = MXC.toJson(data);
		if(json.code == 1) {
			alert('设置成功！');
			location.reload();
		} else {
			alert('设置失败！');
		}
	});
}
function delAddress(id) {
	$('#my-confirm').modal({
		relatedElement: this,
		onConfirm: function() {
			$.post("{:U('Wap/Users/delAddress')}",{addressId:id},function(data,textStatus){
				var json = MXC.toJson(data);
				if(json.code == 1) {
					location.reload();
				} else {
					alert('删除失败！');
				}
			});
			
		},
		onCancel: function() {
		  
		}
	 });
}
</script>
</body>
</html>
